/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import DAOClass.*;

/**
 *
 * @author Phong
 */
public class feed extends HttpServlet {
   
   feedback f = new feedback();


    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        doPost(request, response);
    } 


    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {

        Date d = new Date();
        SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:MM:s");
        String dateSend = df.format(d);

        PrintWriter out = response.getWriter();

        String u = request.getParameter("u");
        String tit = request.getParameter("tit");
        String content = request.getParameter("content");
        String mail = request.getParameter("mail");
        String tel = request.getParameter("tel");

        if(f.Insert(u, tit, content, mail, tel, dateSend, 0))   {
            response.sendRedirect("include/feed_process.jsp?s=success");
        } else {
            response.sendRedirect("include/feed_process.jsp?s=error");
            /*out.println(u+"<br>");
            out.println(tit+"<br>");
            out.println(content+"<br>");
            out.println(mail+"<br>");
            out.println(tel+"<br>");
            out.println(dateSend+"<br>");*/

        }

    }


    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
